package per.dg.basicusethread.creatandrunthread

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import per.dg.basicusethread.R
import java.util.concurrent.Callable
import java.util.concurrent.FutureTask

class CreatAndRunThreadActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_creat_and_run_thread)

        CustomThread().start()

        Thread(CustomRunnable()).start()

        Thread(FutureTask(CustomCallable<Int>())).start()
    }

    class CustomThread : Thread(){
        override fun run() {
            Log.e(per.dg.basicusethread.TAG, "CustomThread 已运行")
        }
    }

    class CustomRunnable : Runnable{
        override fun run() {
            Log.e(per.dg.basicusethread.TAG, "CustomRunnable 已运行")
        }
    }

    class CustomCallable<T> : Callable<T> {
        override fun call(): T? {
            Log.e(per.dg.basicusethread.TAG, "CustomCallable 已运行")
            return null
        }
    }
}